<template>
	<view :class="['vh100',{'dark':theme == 'dark'}]">

		<!-- 这个接口 对接后台的 客服应用里的参数，前面的版本 苹果跟安卓参数接口对接后台的参数，版本号对接后台的版本号即可 -->
		<view class="ptb20 ft14 flex alcenter between plr10 bdb_blue3">
			<span>{{$t('bico.W614')}}</span>
			<!-- 当前版 不需要写参数对接默认这个介绍名称即可，版本号对接后台的版本参数。后台写什么，这个页面的版本都会跟着改变 -->
			<span class="flex alcenter">{{myVersion}}</span>
			<!-- 加后台参数 -->
		</view>
		<!-- 点击事件 触发下载-->
		<!-- 点击的链接下载地址也要对接后台的参数实现点击下载更新 -->
		<navigator url="/" class="ptb20 ft14 flex alcenter between plr10 bdb_blue3">
			<span>{{$t('bico.W615')}}</span>
			<!-- 加后台参数 -->
			<span class="flex alcenter">{{iosVersion}}</span>
			<!-- 加后台参数 -->
			
		</navigator>
		<!-- 点击事件 触发下载-->
		<!-- 点击的链接下载地址也要对接后台的参数实现点击下载更新 -->
		<navigator url="/" class="ptb20 ft14 flex alcenter between plr10 bdb_blue3">
			<span>{{$t('bico.W616')}}</span>
			<!-- 加后台参数 -->
			<span class="flex alcenter">{{androidVersion}}</span>
			<!-- 加后台参数 -->
		</navigator>
	</view>
</template>

<script>
	import {
		mapState,
		mapActions,
		mapGetters
	} from 'vuex';
	import {
		commonVersion
	} from '../../common/apiString.js'
	import {
		myMixins
	} from '@/common/myMixins.js' //加入全局下拉刷新
	export default {
		mixins: [myMixins],
		data() {
			return {
				androidVersion: '',
				iosVersion: '',
				myVersion:'1.0.0'
			}
		},
		computed: {
			...mapState({
				theme: state => state.theme
			}),
		},
		onLoad() {
			uni.setNavigationBarTitle({
				title: this.$t('bico.W617'),
			})
			this.$utils.setTheme(this.theme);
			this.getData()
		},
		methods: {
			getData() {
				this.$utils.initData({
					url: commonVersion,
					data: {
						type: 'IOS'
					},
					type: 'post'
				}, (res, msg) => {
					this.iosVersion = res.version
					if(this.isAndroidOrIOS()=='ios'){
						this.myVersion=this.iosVersion
					}
				})
				this.$utils.initData({
					url: commonVersion,
					data: {
						type: 'ANDROID'
					},
					type: 'post'
				}, (res, msg) => {
					this.androidVersion = res.version
					if(this.isAndroidOrIOS()=='android'){
						this.myVersion=this.androidVersion
					}
				})
				
			},
			//判断当前设备是ios还是安卓
			isAndroidOrIOS() {
				var u = navigator.userAgent;
				var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
				var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
				if (isAndroid) {
					return "android"
				}
				if (isiOS) {
					return "ios"
				}
				return false
			}
		}
	}
</script>

<style>
</style>
